package com.yonyou.pmclouds.ncinvoker.thread;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class NCThreadPool {

    private  ThreadPoolExecutor executor = null;

    private NCThreadPool() {
        executor = new ThreadPoolExecutor(20,
                100,
                30L,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(1000),
                new ThreadPoolExecutor.DiscardPolicy()); // 目前简单粗暴的拒绝，认为nc直调应该不会出现这么大的并发量
    }

    public static NCThreadPool getInstance(){
        return SingletonInnerClass.instance;
    }

    private static class SingletonInnerClass{
        private static  NCThreadPool instance = new NCThreadPool();
    }

    public ThreadPoolExecutor getExecutor(){
        return executor;
    }

}
